import 'package:flutter/material.dart';

/*
 * @author[hansen]
 * @version[创建日期，2022/5/27 18:10]
 * @function[文本-文本-箭头]
 */

class TextTextArrowWidget extends StatelessWidget {
  final String? text;
  final String? arrowText;
  final String? arrowHint;
  final TextStyle? textStyle;
  final TextStyle? arrowTextStyle;
  final TextStyle? arrowHintStyle;
  final TextAlign? arrowTextAlign;
  final int? arrowMaxLines;
  final bool? showArrowIcon;
  final IconData? arrowIcons;
  final double? arrowIconSize;
  final Color? arrowIconColor;
  final double space;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;
  final CrossAxisAlignment crossAxisAlignment;
  final Color? backgroundColor;

  const TextTextArrowWidget({
    Key? key,
    this.text,
    this.arrowText,
    this.arrowHint,
    this.textStyle,
    this.arrowTextStyle,
    this.arrowHintStyle,
    this.arrowTextAlign,
    this.arrowMaxLines,
    this.showArrowIcon,
    this.arrowIcons,
    this.arrowIconSize,
    this.arrowIconColor,
    this.space = 20,
    this.padding,
    this.margin,
    this.backgroundColor,
    this.crossAxisAlignment = CrossAxisAlignment.center,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: margin,
      color: backgroundColor,
      padding: padding ?? const EdgeInsets.fromLTRB(15, 10, 15, 10),
      child: Row(
        crossAxisAlignment: crossAxisAlignment,
        children: [
          Text(
            text ?? '',
            style: textStyle ??
                const TextStyle(
                  color: Color(0xFF909399),
                  fontSize: 14,
                ),
          ),
          SizedBox(
            width: space,
          ),
          Expanded(
            child: Text(
              arrowText != null && arrowText!.isNotEmpty
                  ? arrowText!
                  : arrowHint ?? '',
              maxLines: arrowMaxLines ?? 1,
              textAlign: arrowTextAlign ?? TextAlign.end,
              overflow: TextOverflow.ellipsis,
              style: arrowText != null && arrowText!.isNotEmpty
                  ? arrowTextStyle ??
                      const TextStyle(
                        color: Color(0xFF303133),
                        fontSize: 14,
                      )
                  : arrowHintStyle ??
                      const TextStyle(
                        color: Color(0xFFC0C4CC),
                        fontSize: 14,
                      ),
            ),
          ),
          Visibility(
            child: Container(
              margin: const EdgeInsets.only(
                left: 5,
              ),
              child: Icon(
                arrowIcons ?? Icons.arrow_forward_ios_rounded,
                color: arrowIconColor ?? Colors.grey,
                size: arrowIconSize ?? 14,
              ),
            ),
            visible: showArrowIcon ?? true,
          )
        ],
      ),
    );
  }
}
